﻿using System.ServiceModel;
using Metro.Kashikoi.Common.Entity;
using Metro.Kashikoi.Common.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF;
using Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

namespace Metro.Kashikoi.ServiceContract.Location
{
    /// <summary>
    /// This interface provides method to manage the location.
    /// </summary>
    [ServiceContractAttribute]
    [ExceptionShielding]
    public interface ILocationService
    {
        /// <summary>
        /// Creates the organization.
        /// </summary>
        /// <param name="organization">The organization.</param>
        /// <returns>The newly created organization.</returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        Organization CreateOrganization(Organization organization);

        /// <summary>
        /// Updates the organization.
        /// </summary>
        /// <param name="organization">The organization.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void UpdateOrganization(Organization organization);

        /// <summary>
        /// Deleles the organization.
        /// </summary>
        /// <param name="organizationId">The organization id.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void DeleleOrganization(
            [RangeValidator(0, RangeBoundaryType.Exclusive, int.MaxValue, RangeBoundaryType.Exclusive)]
            int organizationId);

        /// <summary>
        /// Gets the default organization.
        /// </summary>
        /// <returns>The default organization.</returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        Organization GetDefaultOrganization();

        /// <summary>
        /// Gets the organization.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>The organization with the specific name.</returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        Organization GetOrganization(
            [StringLengthValidator(1, 255)]
            string name);

        /// <summary>
        /// Creates the facility.
        /// </summary>
        /// <param name="facility">The facility.</param>
        /// <param name="organizationId">The organization id.</param>
        /// <returns>The newly created facility.</returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        Facility CreateFacility(Facility facility,
            [RangeValidator(0, RangeBoundaryType.Exclusive, int.MaxValue, RangeBoundaryType.Exclusive)]
            int organizationId);

        /// <summary>
        /// Updates the facility.
        /// </summary>
        /// <param name="facility">The facility.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void UpdateFacility(Facility facility);

        /// <summary>
        /// Deletes the facility.
        /// </summary>
        /// <param name="facilityId">The facility Id.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void DeleteFacility(
            [RangeValidator(0, RangeBoundaryType.Exclusive, int.MaxValue, RangeBoundaryType.Exclusive)]
            int facilityId);

        /// <summary>
        /// Creates the unit.
        /// </summary>
        /// <param name="unit">The unit.</param>
        /// <param name="facilityId">The facility id.</param>
        /// <returns>The newly created unit.</returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        Unit CreateUnit(Unit unit,
            [RangeValidator(0, RangeBoundaryType.Exclusive, int.MaxValue, RangeBoundaryType.Exclusive)]
            int facilityId);

        /// <summary>
        /// Updates the unit.
        /// </summary>
        /// <param name="unit">The unit.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void UpdateUnit(Unit unit);

        /// <summary>
        /// Deletes the unit.
        /// </summary>
        /// <param name="unitId">The unit id.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void DeleteUnit(
            [RangeValidator(0, RangeBoundaryType.Exclusive, int.MaxValue, RangeBoundaryType.Exclusive)]
            int unitId);

        /// <summary>
        /// Creates the stock area.
        /// </summary>
        /// <param name="stockArea">The stock area.</param>
        /// <param name="unitId">The unit id.</param>
        /// <returns>The newly created stock area.</returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        StockArea CreateStockArea(StockArea stockArea,
            [RangeValidator(0, RangeBoundaryType.Exclusive, int.MaxValue, RangeBoundaryType.Exclusive)]
            int unitId);

        /// <summary>
        /// Updates the stock area.
        /// </summary>
        /// <param name="stockArea">The stock area.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void UpdateStockArea(StockArea stockArea);

        /// <summary>
        /// Deletes the stock area.
        /// </summary>
        /// <param name="stockAreaId">The stock area id.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void DeleteStockArea(
            [RangeValidator(0, RangeBoundaryType.Exclusive, int.MaxValue, RangeBoundaryType.Exclusive)]
            int stockAreaId);

        /// <summary>
        /// Gets the stock area.
        /// </summary>
        /// <param name="stockAreaId">The stock area id.</param>
        /// <returns>The stock area.</returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        StockArea GetStockArea(
            [RangeValidator(0, RangeBoundaryType.Exclusive, int.MaxValue, RangeBoundaryType.Exclusive)]
            int stockAreaId);
    }
}
